﻿@model IEnumerable<Department>
@{
    ViewData["Title"] = "部门";
}

<form asp-area="Admin" asp-controller="User" asp-action="CreateDepartment" method="post" class="form-horizontal">
    <hr />
    <div asp-validation-summary="All" class="text-danger"></div>
    <div class="form-group">
        <span class="col-md-2 control-label">部门名</span>
        <div class="col-md-4">
            <input name="Name" class="form-control" />
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <button type="submit" class="btn btn-default col-md-2">创建</button>
        </div>
    </div>
</form>

@if (Model != null)
{
    <div id="sections" class="panel panel-default">
        <div class="panel-heading">部门列表</div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>
                                @Html.DisplayNameFor(model => model.Name)
                            </th>
                            <th class="col-lg-1"></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    @item.Name
                                </td>
                                <td><a asp-action="DeleteDepartment" asp-route-id="@item.Id" onclick="javascript:if(confirm('确定要删除此信息吗？')){return true;}return false;">删除</a></td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
}
@section Scripts {
    @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
